<style scoped>
    .width70{width:70%;}
    .marginL{margin-left:5px;}
</style>
<template id="MaintenanceSampling">
    <div>
        <el-form :inline="true" :model="formInline" class="demo-form-inline" style="border-bottom:1px solid #ccc;">
            <!--维修站编码-->
            <el-form-item :label="nowLangue.maintenanceStationCode" class="selectMB10">
                <el-input v-model="formInline.code" :placeholder="nowLangue.pleaseImport + nowLangue.maintenanceStationCode"></el-input>
            </el-form-item>
            <!--状态-->
            <el-form-item :label="nowLangue.status" class="selectMB10">
                <el-select size="mini" clearable :placeholder="nowLangue.pleaseSelect" v-model="formInline.categoryCode">
                    <el-option v-for="(subClass,index) in spareClassList" :key="index" :label="subClass.name" :value="subClass.code"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item class="selectMB10">
                <el-button class="bolder outsideBtnBS selectAll" :disabled="selectDisabled" size="mini" type="danger" v-text="nowLangue.query"></el-button>
            </el-form-item>
        </el-form>
        <!--表格-->
        <label class="default-label" v-text="nowLangue.maintenanceSamplingDetails"><!--维修站抽样比例明细--></label>
        <!--新增按钮-->
        <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="createNew()" v-text="nowLangue.newAdd"><!--新增--></el-button>
        <el-table :data="tableData" border style="width: 100%;" v-loading.body="loading" :element-loading-text="nowLangue.isLoading">
            <!--序-->
            <el-table-column type="index" header-align="center" align="center" :label="nowLangue.sequence" width="40"></el-table-column>
            <!--操作-->
            <el-table-column :label="nowLangue.operate" header-align="center" align="center" width="120">
                <template scope="scope">
                    <button class="operationItem bolder" :disabled="forbiddenDisabled" v-if="scope.row.status" @click="handleStatus(scope.$index,scope.row)" v-text="nowLangue.forbidden"></button>
                    <button class="operationItem bolder" :disabled="enableDisabled" v-else @click="handleStatus(scope.$index,scope.row)" v-text="nowLangue.enable"></button>
                    <button class="operationItem bolder" :disabled="scope.row.status" @click="update(scope.$index,scope.row)" v-text="nowLangue.update"></button>
                    <!--审核-->
                    <button class="operationItem bolder"  @click="toExam(scope.$index,scope.row)" v-text="nowLangue.exam"></button>
                </template>
            </el-table-column>
            <!--维修站-->
            <el-table-column prop="" :label="nowLangue.maintenanceStation" header-align="center" show-overflow-tooltip></el-table-column>
            <!--维修站编码-->
            <el-table-column prop="" :label="nowLangue.maintenanceStationCode" header-align="center" show-overflow-tooltip></el-table-column>
            <!--状态-->
            <el-table-column prop="" :label="nowLangue.status" header-align="center" show-overflow-tooltip></el-table-column>
            <!--抽样比例-->
            <el-table-column prop="" :label="nowLangue.sampling" header-align="center" show-overflow-tooltip></el-table-column>
            <!--说明-->
            <el-table-column prop="" :label="nowLangue.describe" header-align="center" show-overflow-tooltip></el-table-column>
            <!--创建人-->
            <el-table-column prop="" :label="nowLangue.creator" header-align="center" show-overflow-tooltip></el-table-column>
            <!--创建时间-->
            <el-table-column prop="" :label="nowLangue.createTime" header-align="center" show-overflow-tooltip></el-table-column>
            <!--审核意见-->
            <el-table-column prop="" :label="nowLangue.examIdea" header-align="center" show-overflow-tooltip></el-table-column>
            <!--审核人-->
            <el-table-column prop="" :label="nowLangue.examor" header-align="center" show-overflow-tooltip></el-table-column>
            <!--审核时间-->
            <el-table-column prop="" :label="nowLangue.examTime" header-align="center" show-overflow-tooltip></el-table-column>
        </el-table>
        <el-pagination v-if="isPaging"  @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="currentPage3" :current-page="pageIndex"  :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :page-count="totalPage" :total="totalNumber"></el-pagination>

        <!--新增弹窗-->
        <el-dialog :title="nowLangue.addMaintenanceSampling" :visible.sync="dialogAddVisible" size="tiny" :lock-scroll=false>
            <el-form :inline="true" :model="addForm" class="demo-form-inline label-minW95" style="border-bottom:1px solid #ccc;" ref="addForm">
                <!--维修站编码-->
                <el-form-item :label="nowLangue.maintenanceStationName" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input size="mini" class="disabledClick" disabled v-model="addForm.groupCode2" icon="search"></el-input>
                </el-form-item>
                <!--维修站名称-->
                <el-form-item :label="nowLangue.maintenanceStationName" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input v-model="addForm.code" class="disabledClick" disabled></el-input>
                </el-form-item>
                <!--抽样比例-->
                <el-form-item :label="nowLangue.sampling" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input class="width70" v-model="addForm.code" :placeholder="nowLangue.pleaseImport"></el-input><span class="marginL">%</span>
                </el-form-item>
                <!--说明-->
                <el-form-item :label="nowLangue.describe" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input v-model="addForm.code" type="textarea" resize="none" :placeholder="nowLangue.pleaseImport"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" v-text="nowLangue.sure"></el-button>
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" v-text="nowLangue.cancel"></el-button>
            </div>
        </el-dialog>
        <!--修改弹窗-->
        <el-dialog :title="nowLangue.updateMaintenanceSampling" :visible.sync="dialogUpdateVisible" size="tiny" :lock-scroll=false>
            <el-form :inline="true" :model="updateForm" class="demo-form-inline label-minW95" style="border-bottom:1px solid #ccc;" ref="updateForm">
                <!--维修站编码-->
                <el-form-item :label="nowLangue.maintenanceStationCode" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input size="mini" class="disabledClick" disabled v-model="updateForm.groupCode2" icon="search"></el-input>
                </el-form-item>
                <!--维修站名称-->
                <el-form-item :label="nowLangue.maintenanceStationName" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input v-model="updateForm.code" class="disabledClick" disabled></el-input>
                </el-form-item>
                <!--抽样比例-->
                <el-form-item :label="nowLangue.sampling" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input class="width70" v-model="updateForm.code" :placeholder="nowLangue.pleaseImport"></el-input><span class="marginL">%</span>
                </el-form-item>
                <!--说明-->
                <el-form-item :label="nowLangue.describe" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input v-model="updateForm.code" type="textarea" resize="none" :placeholder="nowLangue.pleaseImport"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" v-text="nowLangue.sure"></el-button>
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" v-text="nowLangue.cancel"></el-button>
            </div>
        </el-dialog>
        <!--审核弹窗-->
        <el-dialog :title="nowLangue.examMaintenanceSampling" :visible.sync="dialogExamVisible" size="tiny" :lock-scroll=false>
            <el-form :inline="true" :model="examForm" class="demo-form-inline label-minW95" style="border-bottom:1px solid #ccc;" ref="examForm">
                <!--维修站编码-->
                <el-form-item :label="nowLangue.maintenanceStationCode" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input size="mini" class="disabledClick" disabled v-model="examForm.groupCode2" icon="search"></el-input>
                </el-form-item>
                <!--维修站名称-->
                <el-form-item :label="nowLangue.maintenanceStationName" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input v-model="examForm.code" class="disabledClick" disabled></el-input>
                </el-form-item>
                <!--抽样比例-->
                <el-form-item :label="nowLangue.sampling" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input class="width70" v-model="examForm.code" :placeholder="nowLangue.pleaseImport"></el-input><span class="marginL">%</span>
                </el-form-item>
                <!--说明-->
                <el-form-item :label="nowLangue.describe" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input v-model="examForm.code" type="textarea" resize="none" :placeholder="nowLangue.pleaseImport"></el-input>
                </el-form-item>
                <!--审核意见-->
                <el-form-item :label="nowLangue.examIdea" prop="code" :rules="[{ required: true, message: nowLangue.pleaseImport}]">
                    <el-input v-model="examForm.code" type="textarea" resize="none" :placeholder="nowLangue.pleaseImport"></el-input>
                </el-form-item>
                <!--审核后启用-->
                <el-form-item label=" " class="noContent">
                    <el-checkbox v-model="examForm.checked" :label="nowLangue.examOpen"></el-checkbox>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" v-text="nowLangue.examPass"></el-button>
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" v-text="nowLangue.examNotPass"></el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
    export default {
        name:"v-MaintenanceSampling",
        data() {
            return {
                language:{
                    zh:{
                        "pleaseSelect":"请选择",
                        "pleaseImport":"请输入",
                        "query":"查询",
                        "newAdd":"新增",
                        "forbidden":"禁用",
                        "enable":"启用",
                        "update":"修改",
                        "exam":"审核",
                        "check":"查看",
                        "creator":"创建人",
                        "createTime":"创建时间",
                        "isLoading":"正在拼命加载中",
                        "sequence":"序",
                        "operate":"操作",
                        "examNotPass":"审核不通过",
                        "examPass":"审核通过",
                        "examOpen":"审核后通过",
                        "maintenanceStation":"维修站",
                        "maintenanceStationCode":"维修站编码",
                        "maintenanceStationName":"维修站名称",
                        "status":"状态",
                        "sampling":"抽样比例",
                        "describe":"说明",
                        "examIdea":"审核意见",
                        "examor":"审核人",
                        "examTime":"审核时间",
                        "maintenanceSamplingDetails":"维修站抽样比例明细",
                        "addMaintenanceSampling":"新增维修站抽样比例",
                        "updateMaintenanceSampling":"修改维修站抽样比例",
                        "examMaintenanceSampling":"审核维修站抽样比例",
                        "sure":"确定",
                        "cancel":"取消"
                    },
                    en:{
                        "pleaseSelect":"pleaseSelect",
                        "pleaseImport":"pleaseImport",
                        "query":"query",
                        "newAdd":"newAdd",
                        "forbidden":"forbidden",
                        "enable":"enable",
                        "update":"update",
                        "exam":"exam",
                        "check":"check",
                        "creator":"creator",
                        "createTime":"createTime",
                        "isLoading":"isLoading",
                        "sequence":"sequence",
                        "operate":"operate",
                        "examNotPass":"examNotPass",
                        "examPass":"examPass",
                        "examOpen":"examOpen",
                        "maintenanceStation":"maintenanceStation",
                        "maintenanceStationCode":"maintenanceStationCode",
                        "maintenanceStationName":"maintenanceStationName",
                        "status":"status",
                        "sampling":"sampling",
                        "describe":"describe",
                        "examIdea":"examIdea",
                        "examor":"examor",
                        "examTime":"examTime",
                        "maintenanceSamplingDetails":"maintenanceSamplingDetails",
                        "addMaintenanceSampling":"addMaintenanceSampling",
                        "updateMaintenanceSampling":"updateMaintenanceSampling",
                        "examMaintenanceSampling":"examMaintenanceSampling",
                        "sure":"sure",
                        "cancel":"cancel"
                    }
                },
                nowLangue:{},

                formInline:{},
                tableData:[{
                    name:"111"
                }],
                /*新增*/
                dialogAddVisible:false,//新建弹窗
                addForm:{},//新建表单
                /*修改*/
                dialogUpdateVisible:false,//修改弹窗
                updateForm:{},//修改表单
                /*审核*/
                dialogExamVisible:false,//审核弹窗
                examForm:{},//审核表单
                //按钮禁用
                selectDisabled:false,
                enableDisabled:false,
                forbiddenDisabled:false,

                loading:false,
                isPaging:true,    //是否显示分页
                pageIndex:1,    //当前页（必传）
                pageSize :10,   //每页多少条
                currentPage:1,    //当前显示3页
                currentPage3:3,
                totalNumber: 1,     //总条数
                totalPage:1    //总页数

            };
        },
        created:function(){
            var _this=this;
            _this.languageType=="zh"?_this.nowLangue=_this.language.zh:_this.nowLangue=_this.language.en;
        },
        computed:{
            languageType(){
                return this.$store.state.languageType;
            }
        },
        watch:{
            languageType(){
                var _this=this;
                _this.languageType=="zh"?_this.nowLangue=_this.language.zh:_this.nowLangue=_this.language.en;
            }
        },
        //进入页面立即运行此方法
        mounted: function () {
            var _this = this;
            _this.$store.commit('currentActive', 'NTFsampling');
        },
        methods:{
            //备件小类查询
            /*dropSpareList(){
             var _this=this;
             $.ajax({
             type:'GET',
             url:_this.metadata_service+'subClass/findSubClassList',
             cache:false,
             dataType:'JSON',
             contentType:"application/json;charset=utf-8",
             success:function(data){
             if(data.success){
             _this.spareClassList=data.data;
             }else{
             _this.common.errorTip(data.errorMessage);
             }
             }
             })
             },*/
            handleClick(tab, event) {
                /*if(this.activeName=='1'){
                 this.queryEngineer(); // 查询 工程替换组明细
                 }else if(this.activeName=='2'){
                 this.queryFree();  // 查询  自由备件列表
                 }*/
            },
            //查询
            queryEngineer(){
                /*var _this=this;
                 _this.loading=true;
                 _this.loading2=false;
                 var tmp={
                 categoryCode:_this.formInline.categoryCode,
                 code:_this.formInline.code,
                 materialCode:_this.formInline.materialCode,
                 createStartTime:_this.formInline.createStartTime,
                 createEndTime:_this.formInline.createEndTime,
                 pageIndex:_this.pageIndex,
                 pageSize:_this.pageSize
                 };
                 $.ajax({
                 type: 'POST',
                 url: _this.metadata_service+"substituteGroup/queryProjectsstClusterByPage",
                 cache: false,
                 data:JSON.stringify(tmp),
                 dataType:'JSON',
                 contentType: "application/json;charset=utf-8",
                 success: function (data) {
                 if (data.success) {
                 _this.loading=false;
                 _this.isPaging=true;
                 _this.totalPage=data.data.totalPage;
                 _this.totalNumber=data.data.totalNumber;
                 _this.engReplaceData=data.data.dataList;
                 }else{
                 _this.loading=false;
                 _this.common.errorTip(data.errorMessage)
                 }
                 }
                 });*/
            },
            queryFree(){
                /* var _this=this;
                 _this.loading=false;
                 _this.loading2=true;
                 var tmp={
                 productLineId:_this.formInlineFree.productLineId,
                 subclass:_this.formInlineFree.subclass,
                 materialCode:_this.formInlineFree.materialCode,
                 pageIndex:_this.pageIndex2,
                 pageSize:_this.pageSize2
                 };
                 $.ajax({
                 type: 'POST',
                 url: _this.metadata_service+"substituteGroup/queryFreeSpares",
                 cache: false,
                 data:JSON.stringify(tmp),
                 dataType:'JSON',
                 contentType: "application/json;charset=utf-8",
                 success: function (data) {
                 if (data.success) {
                 _this.loading2=false;
                 _this.isPaging2=true;
                 _this.totalPage2=data.data.totalPage;
                 _this.totalNumber2=data.data.totalNumber;
                 _this.freeData=data.data.dataList;
                 }else{
                 _this.loading2=false;
                 _this.common.errorTip(data.errorMessage);
                 }
                 },
                 error:function(err){
                 _this.loading2=false;
                 _this.common.errorTip("Error");
                 }
                 });*/
            },
            //新增
            createNew(){
                this.dialogAddVisible=true;
            },
            // 修改
            update(index,row){
                this.dialogUpdateVisible=true;
            },
            // 查看
            toExam(index,row){
                this.dialogExamVisible=true;
            },
            // 操作启用禁用
            handleStatus(index, row){
                /*var _this=this;
                 if(row.active){
                 row.active = false;
                 }else{
                 row.active = true;
                 }
                 var tmp={id: row.id,status: row.active};
                 $.ajax({
                 type: 'POST',
                 url: _this.metadata_service+"substituteGroup/updateStatus",
                 cache: false,
                 data:JSON.stringify(tmp),
                 dataType:'JSON',
                 contentType: "application/json;charset=utf-8",
                 success: function (data) {
                 if (data.success) {
                 if(row.active){
                 var successMessage1=_this.languageType=="zh"?'启用成功！':'Open Success';
                 _this.common.successTip(successMessage1);
                 }else{
                 var successMessage2=_this.languageType=="zh"?'禁用成功！':'Close Success';
                 _this.common.successTip(successMessage2);
                 }
                 }else
                 _this.common.errorTip(data.errorMessage);
                 }
                 });*/
            },
            //分页
            handleSizeChange(val) {
                // console.log(`每页 ${val} 条`);
                this.pageSize=val;

            },
            //点击页码分页查询点击事件
            handleCurrentChange(val) {
                // console.log(`当前页: ${val}`);
                this.pageIndex=val;

            }
        }
    }
</script>







